﻿using System;
using BizElements.Core;

namespace BizElements.BusinessLayer
{
    internal static class DbTextSourceManager
    {
        private const byte ActiveRecord = 1;

        #region FetchForModule.

        internal static EntityCollection<TextSourceEntity, TextSourceMeta> FetchForModule(string application, string module)
        {
            return RpcHelper.InvokeStaticMethod<EntityCollection<TextSourceEntity, TextSourceMeta>, string, string>(DbFetchForModule, application, module);
        }

        private static EntityCollection<TextSourceEntity, TextSourceMeta> DbFetchForModule(string application, string module)
        {
            TextSourceMeta tbl = new TextSourceMeta();
            SelectStatement select = new SelectStatement(tbl, tbl.Columns);
            select.Where.And(tbl.Application, application);
            select.Where.And(tbl.Module, module);
            select.Where.And(tbl.Status, ActiveRecord);
            return (EntityCollection<TextSourceEntity, TextSourceMeta>)select.Execute();
        }

        #endregion
    }
}